using System;
using System.ComponentModel;
using System.Runtime.Serialization;


namespace WcfService1.DTO
{
    [DataContract]
    public class CoaDTO : INotifyPropertyChanged
    {
        private String _AccountName;
        private String _AccountNumber;
        private String _Category;
        private CurrencyDTO _Currency;
        private int _No;
        private CoaDTO _ParentAccount;
        private Decimal _SaldoAwalDebit;
        private Decimal _SaldoAwalKredit;
        private String _created_by;
        private DateTime? _created_date;
        private String _modified_by;
        private DateTime? _modified_date;
        private string _GeneralInfo;
        private string _KodeVoucher;

        [DataMember]
        public String AccountNumber
        {
            get { return _AccountNumber; }
            set
            {
                _AccountNumber = value;
                RaisePropertyChanged("AccountNumber");
            }
        }


        [DataMember]
        public String AccountName
        {
            get { return _AccountName; }
            set
            {
                _AccountName = value;
                RaisePropertyChanged("AccountName");
            }
        }


        [DataMember]
        public String Category
        {
            get { return _Category; }
            set
            {
                _Category = value;
                RaisePropertyChanged("Category");
            }
        }


        [DataMember]
        public CoaDTO ParentAccount
        {
            get { return _ParentAccount; }
            set
            {
                if(ReferenceEquals(value,_ParentAccount) || value ==null)return;
                _ParentAccount = value;
                RaisePropertyChanged("ParentAccount");
            }
        }


        [DataMember]
        public Decimal SaldoAwalDebit
        {
            get { return _SaldoAwalDebit; }
            set
            {
                _SaldoAwalDebit = value;
                RaisePropertyChanged("SaldoAwalDebit");
            }
        }


        [DataMember]
        public Decimal SaldoAwalKredit
        {
            get { return _SaldoAwalKredit; }
            set
            {
                _SaldoAwalKredit = value;
                RaisePropertyChanged("SaldoAwalKredit");
            }
        }


        [DataMember]
        public CurrencyDTO Currency
        {
            get { return _Currency; }
            set
            {
                _Currency = value;
                RaisePropertyChanged("Currency");
            }
        }


        [DataMember]
        public String created_by
        {
            get { return _created_by; }
            set
            {
                _created_by = value;
                RaisePropertyChanged("created_by");
            }
        }


        [DataMember]
        public DateTime? created_date
        {
            get { return _created_date; }
            set
            {
                _created_date = value;
                RaisePropertyChanged("created_date");
            }
        }

        [DataMember]
        public String modified_by
        {
            get { return _modified_by; }
            set
            {
                _modified_by = value;
                RaisePropertyChanged("modified_by");
            }
        }


        [DataMember]
        public DateTime? modified_date
        {
            get { return _modified_date; }
            set
            {
                _modified_date = value;
                RaisePropertyChanged("modified_date");
            }
        }

        [DataMember]
        public string GeneralInfo
        {
            get { return _GeneralInfo; }
            set
            {
                _GeneralInfo = value;
                RaisePropertyChanged("GeneralInfo");
            }
        }

        [DataMember]
        public string KodeVoucher
        {
            get { return _KodeVoucher; }
            set
            {
                _KodeVoucher = value;
                RaisePropertyChanged("KodeVoucher");
            }
        }

        public int No
        {
            get { return _No; }
            set
            {
                _No = value;
                RaisePropertyChanged("No");
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        protected void RaisePropertyChanged(string propertyname)
        {
            PropertyChangedEventHandler handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyname));
        }


        public override string ToString()
        {
            return this.AccountName + "(" + AccountNumber + ")";
        }
    }
}